package com.xinke.query.common.exception;

import com.xinke.query.common.result.ResultCodeEnum;
import lombok.Getter;

/**
 * 错误类
 */
@Getter
public class GaoSuQueryException extends RuntimeException {
    private Integer code;
    private String message;

    public GaoSuQueryException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public GaoSuQueryException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
        this.message = resultCodeEnum.getMessage();
    }

    public GaoSuQueryException(ResultCodeEnum resultCodeEnum, String message) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
        this.message = resultCodeEnum.getMessage() + ":" + message;
    }

    @Override
    public String toString() {
        return "GaoSuQueryException{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
}
